package DateAndTime;

import java.util.Calendar;

import static java.util.Calendar.MINUTE;

public class Example20 {
    public static void main(String[] args) {
        //获取表示当前时间的calendar对象
        Calendar calendar = Calendar.getInstance();
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH);
        int date = calendar.get(Calendar.DATE);
        int hour = calendar.get(Calendar.HOUR);
        int minute = calendar.get(MINUTE);
        int second = calendar.get(Calendar.SECOND);
        System.out.println("当前时间："+year+"年"+month+"月"+date+"日"+hour+"时"+month+"分"+second+"秒");

    }
}
